Most models of the Nintendo Famicom are equipped with an expansion port for alternative controllers, such as keyboards and light guns. To support up to four players, the expansion port can be equipped with either an adapter to support two additional controllers, or a joystick equipped with a secondary expansion port that will route data from the fourth controller to the primary expansion port.
The NES was designed to accommodate the use of the light gun and robot that were already being used for the Famicom, without making the console more complicated. To accommodate this without redesigning their devices and programs, the ports of the removable joysticks were equipped not only with data line D0, but also D3 and D4. Unfortunately, this prevented games that used other methods of communicating with the Famicom expansion port, including keyboard and four player games, from being released on the NES without major modifications.
To accommodate four player gaming on the NES, Nintendo released the NES Satellite and NES Four Score, which requires games to support another method of reading the joystick ports (first eight reads come from the first controller on the port, second eight reads come from the second controller on the port, followed by another 8 reads that includes a signature, letting the game know whether or not a four-player device is plugged in).